// iview
// import Affix from 'cxivm/src/components/affix'
// import Alert from 'cxivm/src/components/alert'
// import AutoComplete from 'cxivm/src/components/auto-complete'
// import Avatar from 'cxivm/src/components/avatar'
// import BackTop from 'cxivm/src/components/back-top'
// import Badge from 'cxivm/src/components/badge'
// import Breadcrumb from 'cxivm/src/components/breadcrumb'
import Button from 'cxivm/src/components/button'
// import Card from 'cxivm/src/components/card'
// import Carousel from 'cxivm/src/components/carousel'
// import Cascader from 'cxivm/src/components/cascader'
// import Checkbox from 'cxivm/src/components/checkbox'
// import Circle from 'cxivm/src/components/circle'
// import Collapse from 'cxivm/src/components/collapse'
// import ColorPicker from 'cxivm/src/components/color-picker'
// import Content from 'cxivm/src/components/content'
// import DatePicker from 'cxivm/src/components/date-picker'
// import Dropdown from 'cxivm/src/components/dropdown'
// import Footer from 'cxivm/src/components/footer'
// import Form from 'cxivm/src/components/form'
// import Header from 'cxivm/src/components/header'
import Icon from 'cxivm/src/components/icon'
// import Input from 'cxivm/src/components/input'
// import InputNumber from 'cxivm/src/components/input-number'
// import Scroll from 'cxivm/src/components/scroll'
// import Layout from 'cxivm/src/components/layout'
// import LoadingBar from 'cxivm/src/components/loading-bar'
// import Menu from 'cxivm/src/components/menu'
import Message from 'cxivm/src/components/message'
import Modal from 'cxivm/src/components/modal'
// import Notice from 'cxivm/src/components/notice'
// import Page from 'cxivm/src/components/page'
// import Poptip from 'cxivm/src/components/poptip'
// import Progress from 'cxivm/src/components/progress'
// import Radio from 'cxivm/src/components/radio'
// import Rate from 'cxivm/src/components/rate'
// import Sider from 'cxivm/src/components/sider'
// import Slider from 'cxivm/src/components/slider'
// import Spin from 'cxivm/src/components/spin'
// import Steps from 'cxivm/src/components/steps'
// import Switch from 'cxivm/src/components/switch'
// import Table from 'cxivm/src/components/table'
// import Tabs from 'cxivm/src/components/tabs'
// import Tag from 'cxivm/src/components/tag'
import Timeline from 'cxivm/src/components/timeline'
// import TimePicker from 'cxivm/src/components/time-picker'
// import Tooltip from 'cxivm/src/components/tooltip'
// import Transfer from 'cxivm/src/components/transfer'
// import Tree from 'cxivm/src/components/tree'
// import Upload from 'cxivm/src/components/upload'
// import { Row, Col } from 'cxivm/src/components/grid'
// import { Select, Option, OptionGroup } from 'cxivm/src/components/select'
import locale from 'cxivm/src/locale/index'

// vux
// import popup from 'cxivm/src/components/v-popup'
// import popupPicker from 'cxivm/src/components/v-popup-picker'
// import previewer from 'cxivm/src/components/v-previewer'
// import datetime from 'cxivm/src/components/v-datetime'
// import AlertPlugin from 'cxivm/src/plugins/alert/index.js'
import confirmPlugin from 'cxivm/src/plugins/confirm/index.js'
import toastPlugin from 'cxivm/src/plugins/toast/index.js'
// custom
// import pullRefresh from 'cxivm/src/components/c-pullRefresh'
// import fixButton from 'cxivm/src/components/c-fixButton'
import cjcNav from 'cxivm/src/components/c-nav'
const components = {
    // Affix,
    // Alert,
    // AutoComplete,
    // Avatar,
    // BackTop,
    // Badge,
    // Breadcrumb,
    // BreadcrumbItem: Breadcrumb.Item,
    Button,
    // ButtonGroup: Button.Group,
    // Card,
    // Carousel,
    // CarouselItem: Carousel.Item,
    // Cascader,
    // Checkbox,
    // CheckboxGroup: Checkbox.Group,
    // Col,
    // Collapse,
    // ColorPicker,
    // Content: Content,
    // DatePicker,
    // Dropdown,
    // DropdownItem: Dropdown.Item,
    // DropdownMenu: Dropdown.Menu,
    // Footer: Footer,
    // Form,
    // FormItem: Form.Item,
    // Header: Header,
    Icon,
    // Input,
    // InputNumber,
    // Scroll,
    // Sider: Sider,
    // Submenu: Menu.Sub,
    // Layout: Layout,
    // LoadingBar,
    // Menu,
    // MenuGroup: Menu.Group,
    // MenuItem: Menu.Item,
    Message,
    Modal,
    // Notice,
    // Option: Option,
    // OptionGroup,
    // Page,
    // Panel: Collapse.Panel,
    // Poptip,
    // Progress,
    // Radio,
    // RadioGroup: Radio.Group,
    // Rate,
    // Row,
    // Select,
    // Slider,
    // Spin,
    // Step: Steps.Step,
    // Steps,
    // Table,
    // Tabs: Tabs,
    // TabPane: Tabs.Pane,
    // Tag,
    Timeline,
    TimelineItem: Timeline.Item,
    // TimePicker,
    // Tooltip,
    // Transfer,
    // Tree,
    // Upload
}

const vux = {
    // popupPicker: popupPicker,
    // popup,
    // previewer,
    // datetime,
    // AlertPlugin,
    confirmPlugin,
    toastPlugin
}
const custom = {
    // pullRefresh: pullRefresh,
    // fixButton,
    cjcNav
}
const iview = {
    ...components,
    ...vux,
    ...custom,
    iButton: Button,
    // iCircle: Circle,
    // iCol: Col,
    // iContent: Content,
    // iForm: Form,
    // iFooter: Footer,
    // iHeader: Header,
    // iInput: Input,
    // iMenu: Menu,
    // iOption: Option,
    // iProgress: Progress,
    // iSelect: Select,
    // iSwitch: Switch,
    // iTable: Table
}

const install = function(Vue, opts = {}) {
    if (install.installed) return
    locale.use(opts.locale)
    locale.i18n(opts.i18n)

    Object.keys(iview).forEach(key => {
        Vue.component(key, iview[key])
    })

    // Vue.prototype.$Loading = LoadingBar
    Vue.prototype.$Message = Message
    Vue.prototype.$Modal = Modal
    // Vue.prototype.$Notice = Notice
    // Vue.prototype.$Spin = Spin
}

// auto install
if (typeof window !== 'undefined' && window.Vue) {
    install(window.Vue)
}

const API = {
    version: process.env.VERSION, // eslint-disable-line no-undef
    locale: locale.use,
    i18n: locale.i18n,
    install,
    // Circle,
    // Switch,
    ...components,
    ...vux,
    ...custom,
}

API.lang = (code) => {
    const langObject = window['iview/locale'].default
    if (code === langObject.i.locale) locale.use(langObject)
    else console.log(`The ${code} language pack is not loaded.`) // eslint-disable-line no-console
}

export default API // eslint-disable-line no-undef
